package domain;

import java.util.Collection;
import java.util.HashSet;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Entity;

import javax.persistence.OneToMany;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.SafeHtml;
import org.hibernate.validator.constraints.SafeHtml.WhiteListType;

@Entity
@Access(AccessType.PROPERTY)
public class Team extends DomainEntity {
	
	// Constructors
	
	public Team(){
		super();
		users = new HashSet<User>();
		requirements = new HashSet<Requirement>();
	}
	
	// Attributes
	
	private String name;
	private String description;
	
	@NotNull
	@NotBlank
	@SafeHtml( whitelistType = WhiteListType.NONE )
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@NotNull
	@NotBlank
	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	// Relationships
	
	private Collection<User> users;
	private Collection<Requirement> requirements;

	@NotNull
	@Valid
	@OneToMany(mappedBy="group")
	public Collection<Requirement> getRequirements() {
		return requirements;
	}

	public void setRequirements(Collection<Requirement> requirements) {
		this.requirements = requirements;
	}
	
	
	@NotNull
	@Valid
	@OneToMany(mappedBy="group")
	public Collection<User> getUsers() {
		return users;
	}

	public void setEvaluations(Collection<User> users) {
		this.users = users;
	}

}
